HA$PBExportHeader$w_recalcular_kardex.srw
forward
global type w_recalcular_kardex from w_arg_report
end type
type st_1 from statictext within w_recalcular_kardex
end type
type st_2 from statictext within w_recalcular_kardex
end type
type dp_fini from datepicker within w_recalcular_kardex
end type
type st_3 from statictext within w_recalcular_kardex
end type
type st_4 from statictext within w_recalcular_kardex
end type
type dp_ffin from datepicker within w_recalcular_kardex
end type
type ddlb_almacen from uo_middlb within w_recalcular_kardex
end type
type ddlb_item from uo_middlb within w_recalcular_kardex
end type
type sle_query from singlelineedit within w_recalcular_kardex
end type
type cbx_query from checkbox within w_recalcular_kardex
end type
type gb_1 from groupbox within w_recalcular_kardex
end type
end forward

global type w_recalcular_kardex from w_arg_report
integer width = 2185
integer height = 620
string title = "Recalcular Kardex"
boolean minbox = false
windowtype windowtype = response!
st_1 st_1
st_2 st_2
dp_fini dp_fini
st_3 st_3
st_4 st_4
dp_ffin dp_ffin
ddlb_almacen ddlb_almacen
ddlb_item ddlb_item
sle_query sle_query
cbx_query cbx_query
gb_1 gb_1
end type
global w_recalcular_kardex w_recalcular_kardex

type variables
string isa_alma[],is_alma,isa_item[],is_item
//integer iia_alma[],ii_alma,iia_item[],ii_item
end variables

forward prototypes
public subroutine wf_ejecutar_reporte ()
end prototypes

public subroutine wf_ejecutar_reporte ();Datetime ldt_fecini,ldt_fecfin

ldt_fecini =datetime(date(dp_fini.text),time('00:00:00'))
//ldt_fecfin = datetime(date(dp_ffin.text),time('23:59:59'))
//istr_parm.dw_parm[1].Retrieve(istr_parm.integer_parm[1],istr_parm.integer_parm[2],ldt_fecini,ldt_fecfin)

sqlca.Usp_Recalcular_MKARDEX(istr_parm.integer_parm[2],istr_parm.integer_parm[1], ldt_fecini, "",1)



end subroutine

on w_recalcular_kardex.create
int iCurrent
call super::create
this.st_1=create st_1
this.st_2=create st_2
this.dp_fini=create dp_fini
this.st_3=create st_3
this.st_4=create st_4
this.dp_ffin=create dp_ffin
this.ddlb_almacen=create ddlb_almacen
this.ddlb_item=create ddlb_item
this.sle_query=create sle_query
this.cbx_query=create cbx_query
this.gb_1=create gb_1
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.st_1
this.Control[iCurrent+2]=this.st_2
this.Control[iCurrent+3]=this.dp_fini
this.Control[iCurrent+4]=this.st_3
this.Control[iCurrent+5]=this.st_4
this.Control[iCurrent+6]=this.dp_ffin
this.Control[iCurrent+7]=this.ddlb_almacen
this.Control[iCurrent+8]=this.ddlb_item
this.Control[iCurrent+9]=this.sle_query
this.Control[iCurrent+10]=this.cbx_query
this.Control[iCurrent+11]=this.gb_1
end on

on w_recalcular_kardex.destroy
call super::destroy
destroy(this.st_1)
destroy(this.st_2)
destroy(this.dp_fini)
destroy(this.st_3)
destroy(this.st_4)
destroy(this.dp_ffin)
destroy(this.ddlb_almacen)
destroy(this.ddlb_item)
destroy(this.sle_query)
destroy(this.cbx_query)
destroy(this.gb_1)
end on

event open;
is_item='0'
is_alma='0'
ddlb_almacen.selectitem( 1)
ddlb_item.selectitem( 1)
end event

type cb_2 from w_arg_report`cb_2 within w_recalcular_kardex
integer x = 1742
integer y = 372
end type

event cb_2::clicked;close(parent)
end event

type cb_1 from w_arg_report`cb_1 within w_recalcular_kardex
integer x = 1307
integer y = 372
integer height = 116
end type

event cb_1::clicked;Datetime ldt_fecini,ldt_fecfin
integer li_alma,li_item
string ls_query
ldt_fecini =datetime(date(dp_fini.text),time('00:00:00'))
//ldt_fecfin = datetime(date(dp_ffin.text),time('23:59:59'))
//istr_parm.dw_parm[1].Retrieve(istr_parm.integer_parm[1],istr_parm.integer_parm[2],ldt_fecini,ldt_fecfin)

if f_msj("Esta seguro que desea recalcular?",2) = 2 then return

//If sqlca.Usp_Recalcular_MKARDEX(istr_parm.integer_parm[2],istr_parm.integer_parm[1], ldt_fecini, "",1) <> 0  Then

li_alma = integer(is_alma)
li_item = integer(is_item)

ls_query = "" //sle_query.text
//if isnull(ls_query) then ls_query = ''
//
//if not cbx_query.checked then ls_query = ''

SetPointer(HourGlass!)
If sqlca.Usp_Recalcular_MKARDEX(li_item,li_alma, ldt_fecini,ls_query,1) <> 0  Then
	rollback USING SQLCA ;
	f_msj('Error al insertar al kardex',1)
	
else
	f_msj('El recalculo se realizo satisfactoriamente',4) 
End if
SetPointer(Arrow!)





end event

type dw_1 from w_arg_report`dw_1 within w_recalcular_kardex
integer x = 101
integer y = 1080
integer width = 238
integer height = 92
end type

type st_1 from statictext within w_recalcular_kardex
integer x = 96
integer y = 40
integer width = 329
integer height = 88
boolean bringtotop = true
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Almacenes:"
boolean focusrectangle = false
end type

type st_2 from statictext within w_recalcular_kardex
integer x = 96
integer y = 144
integer width = 329
integer height = 88
boolean bringtotop = true
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Materiales:"
boolean focusrectangle = false
end type

type dp_fini from datepicker within w_recalcular_kardex
integer x = 480
integer y = 236
integer width = 594
integer height = 84
integer taborder = 50
boolean bringtotop = true
boolean border = true
borderstyle borderstyle = stylelowered!
date maxdate = Date("2999-12-31")
date mindate = Date("1800-01-01")
datetime value = DateTime(Date("2011-03-07"), Time("15:22:58.000000"))
integer textsize = -8
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
integer calendarfontweight = 400
boolean todaysection = true
boolean todaycircle = true
end type

type st_3 from statictext within w_recalcular_kardex
integer x = 96
integer y = 252
integer width = 352
integer height = 88
boolean bringtotop = true
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
boolean enabled = false
string text = "Fecha Base:"
boolean focusrectangle = false
end type

type st_4 from statictext within w_recalcular_kardex
boolean visible = false
integer x = 645
integer y = 1012
integer width = 334
integer height = 88
boolean bringtotop = true
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
boolean enabled = false
string text = "Fecha Final:"
boolean focusrectangle = false
end type

type dp_ffin from datepicker within w_recalcular_kardex
boolean visible = false
integer x = 1029
integer y = 1004
integer width = 571
integer height = 80
integer taborder = 40
boolean bringtotop = true
boolean border = true
borderstyle borderstyle = stylelowered!
boolean enabled = false
date maxdate = Date("2999-12-31")
date mindate = Date("1800-01-01")
datetime value = DateTime(Date("2011-03-07"), Time("15:22:58.000000"))
integer textsize = -8
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
integer calendarfontweight = 400
boolean todaysection = true
boolean todaycircle = true
end type

type ddlb_almacen from uo_middlb within w_recalcular_kardex
integer x = 480
integer y = 20
integer width = 1655
boolean bringtotop = true
end type

event constructor;call super::constructor;ddlb_almacen.event ue_rellena('select idalma,tdesc from malmacen order by 1 asc')
end event

event selectionchanged;call super::selectionchanged;is_alma=isa_alma[index] 

ddlb_item.reset( )
ddlb_item.event ue_rellena('select distinct a.iditem,i.tDescCorta from mitem i , mitemalma a where i.iditem = a.iditem and  a.idalma = case "'+is_alma+'" when 0 then a.idalma else   "'+is_alma+'"  end order by 1 asc')

ddlb_item.selectitem( 1)
end event

event ue_rellena;long ll_indice= 1
string ls_campo[]

setpointer(hourglass!)
isa_alma[ll_indice]=STRING(0)
is_columna2[ll_indice]='TODOS()'
this.additem(is_columna2[ll_indice])
ll_indice ++

prepare sqlsa from :as_cadena;
declare cur01 dynamic cursor for sqlsa;
open dynamic cur01 ;
fetch cur01 into :isa_alma[ll_indice], :is_columna2[ll_indice];
do while sqlca.sqlcode=0 
	this.additem(is_columna2[ll_indice])
	ll_indice++
	fetch cur01 into :isa_alma[ll_indice], :is_columna2[ll_indice];
loop
if sqlca.sqlcode = -1 then
   return -1
else
	close cur01 ;
	return 1
end if
setpointer(arrow!)




end event

type ddlb_item from uo_middlb within w_recalcular_kardex
integer x = 480
integer y = 128
integer width = 1655
integer taborder = 20
boolean bringtotop = true
end type

event selectionchanged;call super::selectionchanged;is_item=isa_item[index] 
end event

event ue_rellena;long ll_indice= 1
setpointer(hourglass!)
isa_item[ll_indice]=STRING(0)
is_columna2[ll_indice]='TODOS()'
this.additem(is_columna2[ll_indice])
ll_indice ++

prepare sqlsa from :as_cadena;
declare cur01 dynamic cursor for sqlsa;
open dynamic cur01 ;
fetch cur01 into :isa_item[ll_indice], :is_columna2[ll_indice];
do while sqlca.sqlcode=0 
	this.additem(is_columna2[ll_indice])
	ll_indice++
	fetch cur01 into :isa_item[ll_indice], :is_columna2[ll_indice];
loop
if sqlca.sqlcode = -1 then
   return -1
else
	close cur01 ;
	return 1
end if
setpointer(arrow!)




end event

event constructor;call super::constructor;ddlb_item.reset( )
ddlb_item.event ue_rellena('select distinct a.iditem,i.tDescCorta from mitem i , mitemalma a where i.iditem = a.iditem  order by 2 asc')
end event

type sle_query from singlelineedit within w_recalcular_kardex
integer x = 110
integer y = 632
integer width = 507
integer height = 96
integer taborder = 60
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
boolean enabled = false
borderstyle borderstyle = stylelowered!
end type

type cbx_query from checkbox within w_recalcular_kardex
integer x = 55
integer y = 552
integer width = 73
integer height = 72
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 67108864
end type

event clicked;if this.checked then
	sle_query.enabled = true
else
	sle_query.enabled = false
end if
end event

type gb_1 from groupbox within w_recalcular_kardex
integer x = 82
integer y = 552
integer width = 544
integer height = 204
integer taborder = 60
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 67108864
string text = " Query"
end type

